<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props 函数式组件</title>
</head>
<body>
    <div id="root"> </div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //外部数据
        let obj = {
            name: '凤逍',
            age: 19,
            gender: '男',
            jiaxiang: '石家庄'
        }


        //函数式组件声明  2. 在函数里接收一个参数
        function Student(props){
            //3. 解构 获取数据
            let {name, age, gender} = props;
            return <div>
                    <ul>
                        <li>姓名: {name}</li>    
                        <li>年龄: {age}</li>    
                        <li>性别: {gender}</li>    
                    </ul>
                    <hr />
                </div>
        }

        //渲染
        // ReactDOM.render(<Student name="梅西" age="35" gender="男" />, document.querySelector('#root'));
        //1. 在组件标签中设置属性以及属性值
        // let {name, age, gender} = obj;
        // ReactDOM.render(<Student name={name} age={age} gender={gender} />, document.querySelector('#root'));

        //升级简化
        ReactDOM.render(<Student  {...obj}  />, document.querySelector('#root'));


    </script>
</body>
</html>